package com.qingcheng.controller;


import com.qingcheng.entity.Result;
import com.qingcheng.pojo.user.UserPandect;
import com.qingcheng.service.UserPandectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@RequestMapping("/userpandect")
public class UserPandectController {

    @Autowired
    private UserPandectService userPandectService;

    @GetMapping("/findUserSum")
    public Result findUserSum(){
        String date1 = String.valueOf(LocalDate.now());
        String date2 = String.valueOf(LocalDate.now().minusDays(1));
        String date3 = String.valueOf(LocalDate.now().minusDays(2));
        String date = date1.toString().substring(8,10);
        String date4 = String.valueOf(LocalDate.now().minusDays(Integer.valueOf(date)-1));
//        String date1 = "2017-10-08";
//        String date2 = "2017-10-07";
//        String date3 = "2017-10-06";
//        String date4 = "2017-02-01";
        UserPandect userPandect = userPandectService.findUserSum(date1,date2,date3,date4);
        return new Result(200,"查询成功",userPandect);
    }

}
